import axios from 'axios';
// axios.defaults.headers.post['Content-Type'] = 'application/json';
// import { getToken } from '@/utils/auth'
const getToken = ()=>'';
const service = axios.create({
    // process.env.NODE_ENV === 'development' 来判断是否开发环境
    // easy-mock服务挂了，暂时不使用了
    // baseURL: process.env.NODE_ENV === 'development'?'http://jingju.eye56.com:6012':'https://jinju.eye56.com',
    baseURL: 'https://d-xg.boleme.net​/',
    timeout: 5000,
    // headers:{
    //     'Content-Type':'application/json-patch+json'
    // }
});

service.interceptors.request.use(
    config => {  
        let whiteList = [
        '/api/account/login',
        '/api/account/vcode',
        '/file/upload'
      ],
      url = config.url.replace(config.baseURL, '')

    if (whiteList.indexOf(url) < 0) {
      config.headers['Token'] =  getToken()||'' // 让每个请求携带自定义token
    }
    // if(url.indexOf('/file/upload') >-1){
    // //   config.baseURL='http://file.tashanvip.com/';
    //     config.url='http://file.tashanvip.com/home/upload'
    // }

    // // 登录相关接口处理
    // const loginUrls = [
    //   '/api/GlobPermissionVerificationPlugin/Login',
    //   '/api/GlobPermissionVerificationPlugin/Logout',
    //   '/api/GlobPermissionVerificationPlugin/VerifyCode'
    // ]

    // if (loginUrls.indexOf(config.url) > -1) {
    //   config.baseURL = login_base_url
    // }






        return config;
    },
    error => {
        console.log(error);
        return Promise.reject();
    }
);

service.interceptors.response.use(
    response => {
        if (response.status === 200) {
            return response.data;
        } else {
            Promise.reject();
        }
    },
    error => {
        console.log(error);
        return Promise.reject();
    }
);

export default service;
